package cool.webstudy.admin.constant.enums.rescode;

import lombok.extern.slf4j.Slf4j;

/**
 *
 * @author 莫振双
 * @date 2024/7/17 9:14
 * @description: 用户相关响应状态码枚举类
 */
@Slf4j
public enum UserResCodeEnum implements BaseResCodeEnum {
    RC_USER_NOT_EXIST("10000","用户不存在！"),
    RC_ERROR_PASSWORD("10001","密码错误！"),
    RC_ERROR_CAPTCHA("10002","验证码错误！"),
    RC_ERROR_CREATE("10003","创建用户失败！"),
    RC_ERROR_UPDATE("10004","更新用户失败！"),
    RC_ERROR_BATCH_DELETE("10005","批量删除用户失败！"),
    RC_ERROR_NOT_LOGIN("10006","用户未登录！"),
    ;
    private String code;
    private String msg;
    UserResCodeEnum(String code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
    /**
     * 根据code获取msg静态方法，每个响应状态码枚举类都应有这个方法
     */
    public static UserResCodeEnum getMsgByCode(String code) {
        for (UserResCodeEnum userResCodeEnum : UserResCodeEnum.values()) {
            if (userResCodeEnum.code().equals(code)) {
                return userResCodeEnum;
            }
        }
        log.error("getMsgByCode error:无法获取枚举值");
        return null;
    }
}
